#include <bits/stdc++.h>
#define int long long
using namespace std;
inline int read()
{
    int ans = 0, f = 0;
    char c = getchar();
    while (!isdigit(c))
        f |= c == '-', c = getchar();
    while (isdigit(c))
        ans = (ans << 3) + (ans << 1) + c - 48, c = getchar();
    return f ? -ans : ans;
}
void write(int x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(48 + x % 10);
}
const int N = 1e5 + 5;
int n, a[N], si[N];
vector<int> g[N];
void get_root(int u, int fa, int &root, int &mxrt)
{
    si[u] = 1;
    int mx = 0;
    for (int v : g[u])
        if (v != fa)
        {
            get_root(v, u, root, mxrt);
            si[u] += si[v], mx = max(mx, si[v]);
        }
    if ((mx = max(mx, n - si[u])) < mxrt)
        root = u, mxrt = mx;
}
int dfs(int u, int fa)
{
    if (g[u].size() == 1)
        return a[u];
    int sum = 0;
    for (int v : g[u])
        if (v != fa)
        {
            int k = dfs(v, u);
            if (k == -1)
                return -1;
            sum += k;
        }
    if (sum < a[u] || a[u] - (sum - a[u]) < 0)
        return -1;
    return a[u] - (sum - a[u]);
}
signed main()
{
    freopen("clean.in", "r", stdin);
    freopen("clean.out", "w", stdout);
    int T = read();
    while (T--)
    {
        n = read();
        for (int i = 1; i <= n; ++i)
            a[i] = read(), g[i].clear();
        for (int i = 1; i < n; ++i)
        {
            int u = read(), v = read();
            g[u].push_back(v), g[v].push_back(u);
        }
        int root = 0, mxrt = 1e9;
        get_root(1, 0, root, mxrt);
        puts(dfs(root, 0) == 0 ? "YES" : "NO");
    }
    return 0;
}